package com.cdut.hwadeefsc.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.time.LocalDate;
import java.util.Date;

/**
 * 文章表
 * @TableName articles
 */
@TableName(value ="articles")
public class articles {
    /**
     * 主键ID
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 文章标题
     */
    private String title;

    /**
     * 文章正文内容
     */
    private String content;

    /**
     * 作者ID (关联 users.id)
     */
    private Long authorId;

    /**
     * 文章类型 (e.g., "news", "announcement")
     */
    private String type;

    /**
     * 是否置顶 (1=是, 0=否)
     */
    private Integer isPinned;

    /**
     * 创建时间
     */
    private LocalDate createdAt;

    /**
     * 最后更新时间
     */
    private LocalDate updatedAt;

    /**
     * 主键ID
     */
    public Long getId() {
        return id;
    }

    /**
     * 主键ID
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * 文章标题
     */
    public String getTitle() {
        return title;
    }

    /**
     * 文章标题
     */
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * 文章正文内容
     */
    public String getContent() {
        return content;
    }

    /**
     * 文章正文内容
     */
    public void setContent(String content) {
        this.content = content;
    }

    /**
     * 作者ID (关联 users.id)
     */
    public Long getAuthorId() {
        return authorId;
    }

    /**
     * 作者ID (关联 users.id)
     */
    public void setAuthorId(Long authorId) {
        this.authorId = authorId;
    }

    /**
     * 文章类型 (e.g., "news", "announcement")
     */
    public String getType() {
        return type;
    }

    /**
     * 文章类型 (e.g., "news", "announcement")
     */
    public void setType(String type) {
        this.type = type;
    }

    /**
     * 是否置顶 (1=是, 0=否)
     */
    public Integer getIsPinned() {
        return isPinned;
    }

    /**
     * 是否置顶 (1=是, 0=否)
     */
    public void setIsPinned(Integer isPinned) {
        this.isPinned = isPinned;
    }

    /**
     * 创建时间
     */
    public LocalDate getCreatedAt() {
        return createdAt;
    }

    /**
     * 创建时间
     */
    public void setCreatedAt(LocalDate createdAt) {
        this.createdAt = createdAt;
    }

    /**
     * 最后更新时间
     */
    public LocalDate getUpdatedAt() {
        return updatedAt;
    }

    /**
     * 最后更新时间
     */
    public void setUpdatedAt(LocalDate updatedAt) {
        this.updatedAt = updatedAt;
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        articles other = (articles) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle()))
            && (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent()))
            && (this.getAuthorId() == null ? other.getAuthorId() == null : this.getAuthorId().equals(other.getAuthorId()))
            && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
            && (this.getIsPinned() == null ? other.getIsPinned() == null : this.getIsPinned().equals(other.getIsPinned()))
            && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
            && (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
        result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode());
        result = prime * result + ((getAuthorId() == null) ? 0 : getAuthorId().hashCode());
        result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
        result = prime * result + ((getIsPinned() == null) ? 0 : getIsPinned().hashCode());
        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
        result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", title=").append(title);
        sb.append(", content=").append(content);
        sb.append(", authorId=").append(authorId);
        sb.append(", type=").append(type);
        sb.append(", isPinned=").append(isPinned);
        sb.append(", createdAt=").append(createdAt);
        sb.append(", updatedAt=").append(updatedAt);
        sb.append("]");
        return sb.toString();
    }
}